package oj0417.oj0417_01;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] data = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++){
                data[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++){
                if (j == 0){
                    System.out.print(data[j][i]);
                }else {
                    System.out.print(" " + data[j][i]);
                }
            }
            System.out.println();
        }
        sc.close();
    }
}
